package com.muyu.product.domain.model;

import com.muyu.common.core.web.domain.BaseEntity;
import com.muyu.product.domain.RuleAttrInfo;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.Arrays;
import java.util.List;


/**
 * @author DongZl
 * @description: 规格属性，添加模型
 * @Date 2024-3-4 下午 02:28
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class RuleAttrAddModel extends BaseEntity {

    /**
     * 规格属性名称
     */
    private String name;

    /**
     * 规格属性值集合
     */
    private List<String> valueList;

    public static RuleAttrAddModel infoBuild (RuleAttrInfo ruleAttrInfo) {
        return RuleAttrAddModel.builder()
                .name(ruleAttrInfo.getName())
                .valueList(Arrays.stream(ruleAttrInfo.getAttrValue().split(",")).toList())
                .build();
    }
}
